﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using IndignaFramework.Controllers.Code;
using IndignaFramework.Models;

namespace IndignaFramework.Controllers
{
    public class ConvocatoriaController : Controller
    {
        private Model1Container db = new Model1Container();


        public ActionResult ConvocatoriasActivas(int? cant) {

            var movId = MovimientoHelper.MovimientoId;
            var convocatorias = db.Convocatoria.Where(x => x.Activa == true && x.Fecha >= DateTime.Today && x.UsuarioWebCreadorConvocatoria.Movimiento.id == movId).OrderBy(x => x.Fecha);
            if (cant.HasValue){
                var conv = convocatorias.Take(cant.Value);
                return View(conv);
            }

            return View(convocatorias);
        }

    }
}
